package com.osgix.common.utils;

/**
 * @function 对象工具
 * @author Azheng
 * Mar 14, 2009 10:23:17 AM
 */
public class ObjectUtils {
	/***************************************************************************
	*判断对象o实现的所有接口中是否有szInterface 
	* isInterface(Testclass, "java.io.Serializable") = true
	* isInterface(Testclass, "test.ITest") = true
	* @param c
	* @param szInterface
	* @return
	*/
	public boolean isInterface(Class c, String szInterface) {
		Class[] face = c.getInterfaces();
		for (int i = 0, j = face.length; i < j; i++) {
			if (face[i].getName().equals(szInterface)) {
				return true;
			} else {
				Class[] face1 = face[i].getInterfaces();
				for (int x = 0; x < face.length; x++) {
					if (face1[x].getName().equals(szInterface)) {
						return true;
					} else if (isInterface(face1[x], szInterface)) {
						return true;
					}
				}
			}
		}
		if (null != c.getSuperclass()) {
			return isInterface(c.getSuperclass(), szInterface);
		}
		return false;
	}
}
